Problem Note 34948: Widths specified by informats on ATTRIB statement aren't passed properly
When an informat is specified on the ATTRIB statement, the width of the data value should not exceed the width the informat can handle. When this occurs, an error is produced.
ERROR: Read Access Violation In Task [ DATASTEP )
Under the Full Code tab, the informat specified is NUMX. This informat expects to read numeric data and the width maximum is 32. Since the data value being passed to the informat is 63 characters, which exceeds 32, the above error is produced.
Under normal conditions, reading character data with a numeric informat should produce an 'invalid data' message in the log. This will occur if you specify the informat on the INPUT statement after the variable for which it applies.
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.1 TS1M0 | 9.3 TS1M0 |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M0 | 9.3 TS1M0 |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M0 | 9.3 TS1M0 |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M0 | 9.3 TS1M0 |
Microsoft Windows 2000 Advanced Server | 9.1 TS1M0 | |
Microsoft Windows 2000 Datacenter Server | 9.1 TS1M0 | |
Microsoft Windows 2000 Server | 9.1 TS1M0 | |
Microsoft Windows 2000 Professional | 9.1 TS1M0 | |
Microsoft Windows NT Workstation | 9.1 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M0 | 9.3 TS1M0 |
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M0 | 9.3 TS1M0 |
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M0 | 9.3 TS1M0 |
Microsoft Windows XP Professional | 9.1 TS1M0 | 9.3 TS1M0 |
64-bit Enabled AIX | 9.1 TS1M0 | 9.3 TS1M0 |
64-bit Enabled HP-UX | 9.1 TS1M0 | 9.3 TS1M0 |
64-bit Enabled Solaris | 9.1 TS1M0 | 9.3 TS1M0 |
HP-UX IPF | 9.1 TS1M0 | 9.3 TS1M0 |
Linux | 9.1 TS1M0 | 9.3 TS1M0 |
OpenVMS Alpha | 9.1 TS1M0 | 9.3 TS1M0 |
Tru64 UNIX | 9.1 TS1M0 | 9.3 TS1M0 |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
This code reproduces the error because the width of the value is 63 bytes and the NUMX informat can handle a maximum width of 32.
Although the value to be read is character and NUMX reads numeric data, the problem occurs because of the width.
The workaround code that produces the expected 'invalid data' message follows.
Run this code to write to a file:
data _null_;
file 'c:\myfile.txt';
put 'Reads numeric values with a comma in place of the decimal point ' '09'x;
run;
Read the data assigning the informat with the ATRRIB statement.
data a;
infile 'c:\myfile.txt' dlm='09'x truncover dsd ;
attrib numerf informat=numx12.;
input numerf;
run;
One workaround is to use the COMMAX informat on the ATTRIB statement instead
of NUMX.
data a;
infile 'c:\myfile.txt' dlm='09'x truncover dsd ;
attrib numerf informat=commax12.;
input numerf;
run;
Another workaround is to specify the informat on the INPUT statement
rather than on the ATRRIB statement.
data a;
infile 'c:\myfile.txt' dlm='09'x truncover dsd ;
input numerf numx12.;
run ;
An "invalid data" message is produced in both cases because a numeric informat is reading
character data.
ERROR: Read Access Violation In Task [ DATASTEP )
Exception occurred at (5EFA1151)
Task Traceback
Type: | Problem Note |
Priority: | medium |
Topic: | SAS Reference ==> DATA Step Common Programming Tasks ==> Reading and Writing SAS Data SAS Reference ==> Statements ==> Information ==> ATTRIB
|
Date Modified: | 2011-06-01 13:07:10 |
Date Created: | 2009-02-25 13:49:27 |